package com.demo.conn;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnTest {
	private static String DRIVER_SQL2005="com.microsoft.jdbc.sqlserver.SQLServerDriver";
	private static String DRIVER_SQL2000="com.microsoft.sqlserver.jdbc.SQLServerDriver";
	private static String driverjtds="net.sourceforge.jtds.jdbc.Driver";
	private static String driverClass="oracle.jdbc.driver.OracleDriver";
	private static String dialect="org.hibernate.dialect.Oracle10gDialect";
	private static String url="jdbc:oracle:thin:@localhost:1521:orcl";
	private static String url2005="jdbc:jtds:sqlserver://192.168.1.100:1433;DatabaseName=phsj";
	private static String username="sa";
	private static String password="123";
	static{
		try {
			Driver driver=(Driver) Class.forName(driverjtds).newInstance();
			DriverManager.registerDriver(driver);
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static Connection getConn(){
		try {
			return DriverManager.getConnection(url2005,username,password);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
	public static void main(String[] args) throws SQLException {
		System.out.println(getConn().createStatement().execute("select * from core_user")+" -----------");
	/*	Integer integer=new Integer();
		Integer.i=1;
		Integer.j=2;
		change(integer);
		System.out.println(Integer.i+"       "+Integer.j);*/
	}
	
	public static void change(Integer obj){
		java.lang.Integer tmp=obj.i;
		obj.i=obj.j;
		obj.j=tmp;
	}
	
	static class Integer{
		 static java.lang.Integer i=null;
		 static java.lang.Integer j=null;
	}
}
